public class SingleLinkedListImpl implements SingleLinkedList {
	
	private class Item{
		String str;
		Item next;
	} // Node of the list
	
	private Item head; // First element of the list
	private int count = 0; // Number of elements in the list
	
	public boolean isEmpty(){
		if (count == 0){
			return true;
		}
		else{
			return false;
		}
	}
	
	public  int size(){
		return count;
	}
	
	public  void insertFirst(String value){
		if (head == null){
			Item item = new Item();
			item.str = value;
			item.next = null;
			head = item;
		}
		else{
			Item item = new Item();
			item.str = value;
			item.next = head;
			head = item;
		}
		count++;
		
	}
	
	public void insertLast(String value){
		if (head == null){
			Item item = new Item();
			item.str = value;
			item.next = null;
			head = item;
		}
		else{
			Item item = head;
			while (item.next != null){
				item = item.next;
			}
			Item last = new Item();
			item.next = last;
			last.str = value;
			last.next = null;
		}
		count++;
	}
	
	public void insert(String value, int position){
		int i = 0;
		if (head == null){
			Item item = new Item();
			item.str = value;
			item.next = null;
			head = item;
		}
		else{
			Item item = new Item();
			item = head;
			if (position != 0){
				while (i != (position - 1) && item != null){
					item = item.next;
					i++;
				}
				if (item != null){
					Item item1 = new Item();
					item1.str = value;
					item1.next = item.next;
					item.next = item1;
				}
			}
			else{
				insertFirst(value);
			}
		}	
		count++;
	}
	
	public String get(int position){
		int i = 0; 
		Item item = head;
		while (i != position && item != null){
			item = item.next;
			i++;
		}
		if (item != null){
			return item.str;
		}
		else{
			return null;
		}
	}
	
	public void remove(int position){
		int i = 0;
		if (head != null){
			Item item = new Item();
			item = head;
			if (position != 0){
				while (i != (position - 1) && item != null){
					item = item.next;
					i++;
				}
				item.next = item.next.next;
			}
			else{
				item = item.next;
				head = item;
			}
		count--;
		}
	}
	
	public void clear(){
		while (count != 0){
			remove(count - 1);
		}
	}
	
	public void swap(int pos1, int pos2){
	}
}